// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "OSSInfo.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "OSSTaskLib.generated.h"

DECLARE_DYNAMIC_DELEGATE_TwoParams(FOssProgressCallBack, int, userKey, float, progress);
DECLARE_DYNAMIC_DELEGATE_TwoParams(FOssCompleteCallBack, int, userKey, FString, message);

/**
 * 
 */
UCLASS()
class ALIYUNCPPPLUGIN_API UOSSTaskLib : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
public:
	/*
	* 创建一个oss客户端连接,只需要再启动程序时调用一次 一般在UGameInstance的init中调用
	* 不支持链接多个Bucket
	* @ param outMessage	返回的提示信息
	*/
	UFUNCTION(BlueprintCallable, Category = "ossTool")
		static bool ConstructionOssLink(FString accessKeyId, FString accessKeySecret, FString endpoint, FString& outMessage);

	/*
	* 开始一个同步任务  单个文件不能超过2GB
	* @ param url			下载的url
	* @ param savePath		文件保存路径
	* @ param errorMessge	返回的错误休息
	*/
	UFUNCTION(BlueprintCallable, Category = "ossTool")
		static bool StartBlockDown(FString url, FString savePath,FString& errorMessge);


	/*
	* 开始一个异步任务  单个文件不能超过2GB
	* @ param url			下载的url
	* @ param savePath		文件保存路径
	* @ param userKey		用户可以指定一个唯一id ,下载过程和完成的回调中会返回给用户
	* 方便用户判断任务情况
	* @ param onProgress	任务进度回调
	* @ param onComplete	完成后的回调		
	*/
	UFUNCTION(BlueprintCallable, Category = "ossTool")
		static bool StartAsynchronousDown(
			FString url, FString savePath,int userKey
			, FOssProgressCallBack onProgress, FOssCompleteCallBack onComplete);
	
};
